﻿using System;
using System.Collections.Generic;
using System.Text;

namespace LendLess.Ftp
{
    /// <summary>
    /// 扩展属性
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// 获取文件时间
        /// </summary>
        /// <param name="time">文件时间</param>
        /// <returns>时间</returns>
        public static DateTime? ToDateTime(this WINAPI.FILETIME time)
        {
            if (time.dwHighDateTime == 0 && time.dwLowDateTime == 0)
                return null;

            unchecked
            {
                uint low = (uint)time.dwLowDateTime;
                long ft = (((long)time.dwHighDateTime) << 32 | low);
                return DateTime.FromFileTimeUtc(ft);
            }
        }
    }
}
